package cn.edu.zafu.bigdata.x.wgj.f;
class InvalidAgeException extends Exception{
    public InvalidAgeException(String message){
        super(message);
    }
}
class AgeChecker{
    public static void checkAge(int age) throws InvalidAgeException{
        if(age<18){
            throw new InvalidAgeException("年龄小于18岁，不满足要求。");
        }
    }
}
public class Maina {
    public static void main(String[] args){
        int age =15;
        try{
            AgeChecker.checkAge(age);
            System.out.println("年龄符合要求。");
        }catch (InvalidAgeException e){
            System.out.println("捕获到InvalidAgeException异常"+e.getMessage());
        }
    }
}
